const ID_TOKEN_KEY = "token";
const JEHC_SESSION_ID = "JEHC-SESSION-ID";
const JEHC_ROUTER = "Routers";
const JEHC_ROUTER_NEED_LOAD = "JEHC_ROUTER_NEED_LOAD";
const JEHC_ITEM_ASIDE_MAX="setItemAsideMax";
const JEHC_TAGS_ROUTE_LIST= "TagsRouteList";
const JEHC_TAGS_ROUTE_CURRENT="TagsRouteCurrent";
const JEHC_ITEM_MOBILE="setItemMobile";
const CURRENT_HTTP_SESSION = "Current";   
const JEHC_ROOT_MENU_DATA = "JEHC_ROOT_MENU_DATA";
const JEHC_CURRENT_MENU_DATA = "JEHC_CURRENT_MENU_DATA";
import {setLocalItem,removeLocalItem,getLocalItem} from "@/core/util/jehcUtil.js";  
import Router from "@/router.js";


export const getToken = () => {
//  return window.localStorage.getItem(ID_TOKEN_KEY);////废弃获取token方法
    return getLocalItem(ID_TOKEN_KEY);///通过本地缓存获取
};

export const saveToken = token => {
//  window.localStorage.setItem(ID_TOKEN_KEY, token);////废弃获取token方法
    setLocalItem(ID_TOKEN_KEY, token); ;//通过cookie存储
};

export const destroyToken = () => {
//  window.localStorage.removeItem(ID_TOKEN_KEY);//废弃删除token方法
    removeLocalItem(ID_TOKEN_KEY);//删除本地缓存中token
    removeLocalItem(JEHC_SESSION_ID);//删除本地缓存中sessionid    
    removeLocalItem(JEHC_ROUTER);//删除动态路由
    removeLocalItem(JEHC_ROUTER_NEED_LOAD);//删除是否需要第一次加载
    removeLocalItem(JEHC_ITEM_ASIDE_MAX);//删除是否需要第一次加载
    removeLocalItem(JEHC_TAGS_ROUTE_LIST);//删除是否需要第一次加载
    removeLocalItem(JEHC_TAGS_ROUTE_CURRENT);//删除是否需要第一次加载
    removeLocalItem(JEHC_ITEM_MOBILE);//删除是否需要第一次加载
    removeLocalItem(CURRENT_HTTP_SESSION);//删除当前人session信息如权限
    removeLocalItem(JEHC_ROOT_MENU_DATA);//删除RootMenuData
    removeLocalItem(JEHC_CURRENT_MENU_DATA);//删除当前MenuData
};

/**
 * @description get token form local store
 */
export const getJSessionId = () => {
    return getLocalItem(JEHC_SESSION_ID);///通过本地缓存获取
};

export default { getToken, saveToken, destroyToken ,getJSessionId};
